<%@ page language="java" contentType="text/html; charset=utf-8"  pageEncoding="utf-8"%>
 <%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title>按配送企业设置配送区域</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>按企业设置配送区域</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系设置</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
               <div class="input">    
                    <div class="textalign1">企业名称：</div>
                    <div class="boxinput">
                        <input class="textinput" type="text" name="compName" id="compName" placeholder="企业名称/<spring:message code="message.listForm.pinYinMa"/>" maxlength="64" />
                    </div>
                    
                    <!-- <div class="textalign">企业编码：</div>
                    <div class="boxinput">
                        <input class="textinput" type="text" name="compCode" id="compCode" placeholder="企业编码" maxlength="25" />
                    </div> -->
                    
                    <div class="textalign1" >
                		 <button    id="selectSee" type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm">查&nbsp;询</button>
                 	</div>
              </div>
            </div>
        </div>
         
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
        
		<div class=" box box-warning bottongroup" id="bottongroup">
		<label  onclick="window.location.href='${ctx}/baseGoods/toProDelDrugList.html'"   class="btn btn-danger btn-sm" >返 回</label>
		</div>
<div style="margin-top: 10px;"></div>
<form action="${ctx}/baseGoods/toSetDelArea.html" method="post" id="FormArea">
		<input type="hidden" id="delCompCode" name="compCode">
		<input type="hidden" id="compNameArea" name="compName">
		<input type="hidden" id="goodsCode" name="goodsCode">
		<input type="hidden" id="projID" name="projID">
		<input type="hidden" id="goodsArea" name="goodsArea" value="${param.goodsArea }">
		</form>
		<form action="${ctx}/baseGoods/toDelArea.html" method="post" id="FormDelArea">
		<input type="hidden" id="compId2" name="compCode">
		<input type="hidden" id="compName2" name="compName">
		<input type="hidden" id="goodsCode2" name="goodsCode">
		<input type="hidden" id="projID2" name="projID">
		<input type="hidden" id="goodsArea" name="goodsArea" value="${param.goodsArea }">
		</form>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
$(function () {

	//绑定回车   id="selectSee"
	$('#compName,#compCode').bind('keydown', function(event) {
	    if (event.keyCode == "13") {
	        $('#selectSee').click();
	    }
	}); 
	$("#compName").focus();//加载页面光标在第一个查询框内
	
	
jQuery("#gridlist").jqGrid({
	url: "${ctx}/baseGoods/getDelComp.html?goodsCode=${param.goodsCode}&projID=${param.projID}&goodsArea=${param.goodsArea}",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
//  	height: 285,
   	colNames:['操作','企业编码','企业名称','组织机构代码','联系人','联系电话','配送区域数'],
   	colModel:[
        {name:'oper',index:'formName', width:80, align:"center", sortable:false,formatter:function(val,option,rowdata){
		   var str = "<a href=\"javaScript:toDelAreaJsp('"+rowdata.compCode+"','"+rowdata.compName+"');\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -20px -100px' class='opIcon' title='选择配送区域'></a>";
		   str += "<a href='${ctx}/baseGoods/toDelLogByCompList.html?compCode="+rowdata.compCode+"&compName="+rowdata.compName+"&goodsCode=${param.goodsCode}&projID=${param.projID}&goodsArea=${param.goodsArea }' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='设置日志'></a>";
		   return str;
	    }},
		{name:'compCode',index:'goodsCode', width:140,align:"center", sortable:false,hidden:true},
		{name:'compName',index:'goodsCode', width:140,align:"left", sortable:false},
   		{name:'orgCode',index:'drugName', width:120,align:"center", sortable:false},
   		{name:'contactName',index:'compName', width:120, sortable:false},
   		{name:'contactPhone',index:'areaName', width:120, sortable:false},
   		{name:'areaCount',index:'formName', width:60, align:"center", sortable:false,formatter:function(val,option,rowdata){
   			var str = "<a href=\"javaScript:toAreaJsp('"+rowdata.compCode+"','"+rowdata.compName+"');\">"+val+"</a>";
	   			return str;
   		}}
   		
		
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     pager: "#prowed2",
     viewrecords: true,
     gridComplete: function(){
      	//序号列宽度自适应（参数为jqgridID）
         autoRNWidth("gridlist");
      	//数据只有一条时默认选中（参数为jqgridID）
          selectByOneData("gridlist");
	     },
     caption: "${param.goodsCode}/${form.drugCode}/${form.qualityspecName}/${form.formName}/${form.specName}/${form.factor}${form.unit}/${form.materialName}",
     editurl:"proPlanItemListHis.jsp",
     jsonReader: {
         repeatitems: false,
         id: "ids"
     }
   	
});
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$(window).trigger("resize");
	$("#gridlist").jqGrid("setGridHeight",create());
});

function gridSerch() {
	var compCode = $.trim($("#compCode").val());
	var compName = $.trim($("#compName").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{
        	"compCode":compCode,
        	"compName":compName,
        	"projID":"${param.projID}",
        		"goodsCode":"${param.goodsCode}"}
    }).trigger("reloadGrid"); //重新载入  
}

function toAreaJsp(compCode,compName){
	$("#delCompCode").val(compCode);
	$("#compNameArea").val(compName);
	$("#goodsCode").val("${param.goodsCode}");
	$("#projID").val("${param.projID}");
	$("#FormArea").submit();
}

function toDelAreaJsp(compId,compName){
	$("#compId2").val(compId);
	$("#compName2").val(compName);
	$("#goodsCode2").val("${param.goodsCode}");
	$("#projID2").val("${param.projID}");
	$("#FormDelArea").submit();
}
</script>
</body>
</html>